package mvc;

import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;

public class Logger 
{
	private static Logger instance;
	private Logger(){}
	
	/**
	 * This is to create a logger instance which can be called in other classes
	 * @return instance
	 */
	public static Logger getInstance(){
		if(instance == null)
			instance = new Logger();
		return instance;
	}
	
	/**
	 * This method is to write log record into the Log text file
	 */
	static public void logreport(String log){
		System.out.println(log);
		
		try {
			File f = new File("Log.txt");		
			BufferedWriter bw = new BufferedWriter( new FileWriter(f,true));
			bw.write(log);
			bw.newLine();
			bw.close();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
	}
}
